import { AttributeViewInfo, IObjectAttributeView, IObjectBlockView, IObjectView } from '@feng3d/objectview';
import GUI from 'lil-gui';

export class OAVBase implements IObjectAttributeView
{
    protected _space: any;
    protected _attributeName: string;
    protected _attributeType: string;
    protected _attributeViewInfo: AttributeViewInfo;

    /**
     * 对象属性界面
     */
    objectView: IObjectView;
    /**
     * 对象属性块界面
     */
    objectBlockView: IObjectBlockView;

    constructor(attributeViewInfo: AttributeViewInfo)
    {
        this._space = attributeViewInfo.owner;
        this._attributeName = attributeViewInfo.name;
        this._attributeType = attributeViewInfo.type;
        this._attributeViewInfo = attributeViewInfo;
    }

    get space(): any
    {
        return this._space;
    }

    set space(value: any)
    {
        this._space = value;
        this.dispose();
        this.updateView();
    }

    /**
     * 初始化
     */
    initview(gui: GUI)
    {

    }

    /**
     * 销毁
     */
    dispose()
    {

    }

    /**
     * 更新
     */
    updateView()
    {

    }

    get attributeName(): string
    {
        return this._attributeName;
    }

    get attributeValue(): any
    {
        return this._space[this._attributeName];
    }

    set attributeValue(value: any)
    {
        if (this._space[this._attributeName] !== value)
        {
            this._space[this._attributeName] = value;
        }
    }
}
